/* Сброс стилей */
@import './normalize.css';

/* Переменные */
:root {
    --background-color: rgba(218, 221, 224, 0.76);
    --scrollbar-background: #fff;
    --scrollbar-thumb: lightgray;
    --glow-button-background: #111;
    --glow-button-text: #fff;
    --glow-button-hover: #000;
}

/* Стили полосы прокрутки */
body {
    font-family: Arial, sans-serif;
    background-color: var(--background-color);
    scrollbar-width: thin;
}

/* Фон полосы прокрутки */
body::-webkit-scrollbar-track {
    background-color: var(--scrollbar-background);
    box-shadow: inset 1px 1px 4px rgba(0, 0, 0, 0.1);
}

/* Бегунок полосы прокрутки */
body::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb);
    border-radius: 10px;
}

/* Эффект при наведении на бегунок полосы прокрутки */
body::-webkit-scrollbar-thumb:hover {
    background-color: var(--glow-button-hover);
}

section {
    margin: 5px 0;
}

input[type="text"], input[type="number"], textarea {
    padding: 0 20px;
    margin-bottom: 10px;
    background: #E9EFF6;
    line-height: 40px;
    border-width: 0;
    border-radius: 20px;
}

.calculator {
    max-width: 80%;
    margin: 20px auto;
}

button {
    padding: 10px;
    font-size: 16px;
    cursor: pointer;
}

/* Стили модального окна */
.modal {
    display: none;
    position: fixed;
    z-index: 1;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
    padding-top: 60px;
    animation: fadeInOut 0.3s ease;
}

.modal-container {
    display: flex;
    flex-direction: column;
    padding: 20px;
    background-color: #fefefe;
    margin: 0 auto;
    width: 50%;
    border-radius: 15px;
}

.modal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close:hover,
.close:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

/* Стили формы продукта */
#productForm {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#productForm input {
    max-width: 300px;
}

#productForm label {
    margin-right: 10px;
}

#productForm textarea {
    resize: none;
}

.productForm-wrapper {
    margin-bottom: 10px;
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
}

/* Стили светящейся кнопки */
.glow-on-hover {
    width: 220px;
    height: 50px;
    border: none;
    outline: none;
    color: var(--glow-button-text);
    background: var(--glow-button-background);
    cursor: pointer;
    position: relative;
    z-index: 0;
    border-radius: 10px;
    padding: 5px;
}

.glow-on-hover:before {
    content: '';
    background: linear-gradient(45deg, #ff0000, #ff7300, #fffb00, #48ff00, #00ffd5, #002bff, #7a00ff, #ff00c8, #ff0000);
    position: absolute;
    top: -2px;
    left: -2px;
    background-size: 400%;
    z-index: -1;
    filter: blur(5px);
    width: calc(100% + 4px);
    height: calc(100% + 4px);
    animation: glowing 20s linear infinite;
    opacity: 0;
    transition: opacity .3s ease-in-out;
    border-radius: 10px;
}

.glow-on-hover:active {
    color: #000;
}

.glow-on-hover:active:after {
    background: transparent;
}

.glow-on-hover:hover:before {
    opacity: 1;
}

.glow-on-hover:after {
    z-index: -1;
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: #111;
    left: 0;
    top: 0;
    border-radius: 10px;
}

@keyframes glowing {
    0% { background-position: 0 0; }
    50% { background-position: 400% 0; }
    100% { background-position: 0 0; }
}

.productList-panel {
    display: flex;
    flex-direction: row;
    justify-content: space-around;
}

/* Стили списка продуктов */
.productList-container {
    width: 100%;
    padding: 0 20px;

    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    grid-gap: 10px;
    margin: 20px 0;
}

.productList-filter {
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    padding: 20px 0;

    > * {
        margin-right: 5px;
        height: 40px;
    }
}

/* Стили для удаления продукта */
.product-card {
    position: relative;
    text-align: center;

    .product-card-title {
        display: block;
        margin-bottom: 5px;
        opacity: 0.9;
        font-size: 16px;
        font-weight: bold;
    }
}

.product-card:hover {
    opacity: 0.6;
}

.product-card > * {
    padding: 10px 0;
}

.product-card p {
    margin-bottom: 10px;
}

.product-card .delete-btn{
    position: absolute;
    right: 5px;
    top: 1px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    font-size: 20px;
    color: red;
}

.product-card .delete-btn:hover, .remove-btn:hover {
    color: #ff3030;
}

/* Стили для сообщения о пустом списке продуктов */
.productList-container h3 {
    grid-column: span 2;
    text-align: center;
    color: #555;
}

.calories-goalDisplay {
    font-weight: 600;
    opacity: 0.7;
}

.selectedProducts {
    margin-top: 20px;
}

.selectedProducts-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-start;
}

.selectedProduct-card {
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 10px;
    text-align: center;
    background-color: #fff;
}

.selectedProduct-card-title {
    display: block;
    margin-bottom: 5px;
    opacity: 0.9;
    font-size: 16px;
    font-weight: bold;
}

.selectedProduct-card span {
    display: block;
    margin-bottom: 5px;
}

.selectedProduct-card .delete-btn, .remove-btn {
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    font-size: 20px;
    font-weight: bold;
    color: red;
}

.selected-product-card {
    display: flex;
    flex-direction: row;
    align-items: center;

    > span {
        padding-right: 10px;
    }
}

#totalCalories {
    font-weight: bold;
}

.selectedProduct-card .delete-btn:hover, .remove-btn:hover {
    color: #ff3030;
}

.warning-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #fff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
    padding: 20px;
    border-radius: 8px;
}

.warning-modal-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    font-size: 18px;

    > * {
        margin-right: 10px;
        background: none;
        border: none;
    }
}

.calories-panel {
    display: flex;
    flex-direction: column;

    > * {
        margin-bottom: 10px;
    }
}

/* Анимация для появления/исчезания модального окна */
@keyframes fadeInOut {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Стили для анимации светящейся кнопки */
.glow-on-hover:hover:before {
    opacity: 1;
    animation: glowing 20s linear infinite;
}

/* Стили для списка продуктов в мобильном режиме */
@media screen and (max-width: 884px) {
    .productList-container {
        grid-gap: 10px;
    }

    .productList-panel {
        flex-direction: column;
        align-items: center;
    }

    .productList-panel > * {
        margin-bottom: 5px;
    }

    .modal-container {
        width: 80%;
    }
}
